#ifndef MOUSE_HH_
# define MOUSE_HH_

// # include <GL/glut.h>
// # include "SDL/SDL.h"

# include <map>
# include "mouse_input.hh"
# include "../interfaces/displayable.hh"
# include "../server.hh"
# include "../camera/camera.hh"
# include "../gui/menu/menu-handler.hh"
# include "../raycaster/ray.hh"
# include <request/type.hh>

class Mouse : public Displayable
{
public:
  static const unsigned LEFT_CLICK = 1;
  static const unsigned SCROLL_CLICK = 2;
  static const unsigned RIGHT_CLICK = 3;
  static const unsigned SCROLL_UP = 4;
  static const unsigned SCROLL_DOWN = 5;

  Mouse (MenuHandler* mh, Server* s, Camera* c);
  ~Mouse ();

  // get rid of the camera as it is in the constructor
  void button_pressed (unsigned int button, Camera* c);
  void button_released (unsigned int button, Camera* c);
  void catch_mouse_pos (unsigned int button, Camera* c);

  void erase (unsigned int button);
  bool button_check (unsigned int button) const;

  const std::map<unsigned int, MouseInput*>& input () const { return input_; }

  // mouse input treatment
  void treat ();
  bool handle_left_click ();
  bool handle_right_click ();
  void obj_selection (MouseInput* mi);
  void mono_selection (Ray* ray);
  void multi_selection (Vector3f* base, Vector3f* end);

  int* obj_select () { return obj_select_; }
  int select_size () { return select_size_; }

  void reset_selection ();

  virtual void dispatch () const;
protected:
  std::map<unsigned int, MouseInput*> input_;
  MenuHandler* mh_;
  Server* s_;
  Camera* c_;

  // objet selection
  int* obj_select_;
  int select_size_;

  Vector3f* p_intersect;
  Vector3f* r_intersect;
};

#endif /// !MOUSE_HH_
